package com.itheima.package4_tool;
/*
ConcurrentHashMap:
    默认创建一个长度16，加载因子为0.75的大数组
        大数组一旦创建无法扩容
    创建长度为2的小数组，地址值赋值给0索引处，其他索引处元素为null
 */
import java.util.concurrent.ConcurrentHashMap;

public class MyConcurrentHashMapDemo {
    public static void main(String[] args) throws InterruptedException {
        ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
        new Thread(() -> {
            for (int i = 1; i <= 25; i++) {
                map.put(i + "", i + "");
            }
        }).start();
        new Thread(() -> {
            for (int i = 26; i <= 50; i++) {
                map.put(i + "", i + "");
            }
        }).start();
        System.out.println("----------------------------");
        Thread.sleep(1000);

        map.forEach((k, v) -> System.out.println(k + "=" + v));
    }
}
